<template>
    <div id="addre">
        <div v-if="this.addrelist.length>0" class="ress">
            <ul>
                <li v-for="(item,index) in addrelist" :key="index">
                    <img src="@/assets/img/sh1.png" alt="">
                    <div class="cent" @click="tian(item.id)">
                        <p class="p1">{{item.user_name}} <span>{{item.mobile}}</span> </p>
                        <p class="p2">
                            <span class="mo" v-if="item.is_default==1">默认</span>
                            <span>{{item.province_name+item.city_name+item.district_name+item.address}}</span>
                        </p>
                    </div>
                    <button @click="$router.push('/add?id='+item.id)">编辑</button>
                </li>
            </ul>
        </div>
        <div v-else>
            <van-empty class="custom-image" image="http://120.53.31.103:86/img/empty.0d284c2e.png" description="暂无收货地址" />
        </div>
        <div class="but">
            <button @click="$router.push('/add')">添加新地址</button>
        </div>
    </div>
</template>
<script>
import { addres } from '@/api/user.js'
export default {
  data() {
    return {
      addrelist: []
    }
  },
  methods: {
    async getaddres() {
      let { data: data } = await addres()
      this.addrelist = data.data
      console.log(this.addrelist, 77)
    },
    tian(i){
       this.$router.go(-1)
       this.$store.commit('tian',i)
    }
  },
  created() {
    this.getaddres()
  }
}
</script>
<style lang="scss" scoped>
#addre {
  background: white;
  height: 100%;
}
.but {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px 0px #ccc;

  button {
    background: #e60012;
    border: none;
    width: 90%;
    height: 35px;
    border-radius: 25px;
    color: white;
    font-size: 14px;
  }
}
.ress {
  padding: 0 15px;
  ul {
    li {
      display: flex;
      justify-content: space-between;
      padding: 20px 0;
      align-items: center;
      img {
        width: 30px;
        height: 30px;
      }
      .cent {
        flex: 1;
        margin-left: 10px;
        .p1 {
          font-size: 15px;
          span {
            font-size: 12px;
            color: #8c8c8c;
          }
        }
        .p2 {
          font-size: 12px;
          margin-top: 2px;
          .mo {
            color: #e74d3d;
            background-color: rgba(231, 77, 61, 0.06);
            border: 1px solid rgba(231, 77, 61, 0.3);
            border-radius: 2px;
            font-size: 10px;
            padding: 1px 2px;
          }
        }
      }
      button {
        color: #e74d3d;
        background-color: rgba(231, 77, 61, 0.06);
        border: none;
        width: 55px;
        height: 22px;
        border-radius: 20px;
      }
    }
  }
}
</style>


